﻿/************************************************
 * Copyright (C) 2011 东北农业大学(NEAU)
 * 版权所有。
 * 文件名：StockRoomStuffTypeList.aspx.cs
 * 版本号：v1.0
 * 文件功能描述：材料类型显示
 * 作者：侯建
 * 创建日期：2011.04.18
************************************************/
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jxym.DBUtility;
using Newtonsoft.Json;

namespace Jxym.wlkc2011.Module.Default.server.StockRoomStuff
{
    public partial class StockRoomStuffTypeList : System.Web.UI.Page
    {
        string str = "";
        MsSqlDal<model.StockRoomStuffType> icc = new MsSqlDal<model.StockRoomStuffType>();
        //MsSqlDal<model.StockRoomStuffType> icc = new MsSqlDal<model.StockRoomStuffType>();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params["ContacType"] != null)
            {
                int depmetId = Convert.ToInt32(Request.Params["ContacType"]);
                MsSqlDal<model.StockRoomStuffType> iD = new MsSqlDal<model.StockRoomStuffType>();
                //MsSqlDal<model.StockRoomStuffType> iD = new MsSqlDal<model.StockRoomStuffType>();
                model.StockRoomStuffType dInfo = iD.GetModel("ID=" + depmetId, null);
                if (dInfo != null)
                {
                    str = JsonConvert.SerializeObject(dInfo);
                }
                Response.Write(str);
            }
            else
            {
                IList<model.StockRoomStuffType> icclist = icc.GetList("", null, "", 0);
                if (icclist.Count > 0)
                {
                    str = "[";
                    foreach (model.StockRoomStuffType c in icclist)
                    {
                        str += "{'id':" + c.ID + ",'text':'" + c.StockRoomTypeName + "','leaf':true},";
                    }
                    str = str.TrimEnd(',');
                    str += "]";
                    Response.Write(str);
                }
            }
        }
    }
}